<?php

namespace app\common\model;

class DutyRecord extends \think\Model
{
    use \app\common\model\TimeCommon;
    /**
     * 与此签到记录关联的助理的信息
     *
     * @return void
     */
    public function assistant()
    {
        return $this->belongsTo('Assistant');
    }

    /**
     * 检查当前是否有待签退的记录
     *
     * @return void
     */
    public static function checkSignOut($assistantId)
    {
        $systemConfig = new SystemConfig;
        $data = [
            'term_id' => $systemConfig->getValueInt('CurTerm'),
            'assistant_id' => $assistantId,
            'date' => date('Y-m-d')
        ];
        return DutyRecord::where($data)->whereNotNull('start_time')->whereNull('end_time')->find();
    }
}
